import { CommonForm } from "@/pages/OrderModule/common/components/CommonForm";
import { CommonModal } from "@/views/components/CommonModal";
import CommonTextarea from "@/pages/OrderModule/common/components/CommonTextarea";
import { Form, message } from "antd";
import { batchUpdateNoteGoodsSku } from "@/pages/GoodsModule/systemGoods/service";

// 商品备注仅对自发订单生效

function SkuRemarkModal(props) {
	const { fetchList, selectedKeys, onCancel } = props;
	const [form] = Form.useForm();
	function handleOk() {
		batchUpdateNoteGoodsSku({ ids: selectedKeys, ...form.getFieldsValue() }).then(res => {
			const { success, msg } = res;
			if (success) {
				message.success(msg);
				fetchList();
				onCancel();
			}
		});
	}

	return (
		<CommonModal title={{ title: "商品备注" }} open={true} width="600px" onOk={handleOk} onCancel={onCancel}>
			<CommonForm
				formProps={{
					form
				}}
				columns={[
					{
						name: "note",
						slot: (
							<CommonTextarea
								placeholder="请输入商品备注，仅对自发订单生效，会在扫码打单页面展示；
                名称、颜色规格、件数请写清楚"
								rows={8}
							/>
						)
					}
				]}
			></CommonForm>
		</CommonModal>
	);
}

export default SkuRemarkModal;
